package com.iflysse.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.iflysse.entity.TeachingClass;
import com.iflysse.service.TeachingClassService;
import com.iflysse.utils.CommonUtil;
import com.iflysse.vo.TeachingClassDetailVo;
import com.iflysse.vo.TeachingClassVo;


import com.iflysse.dao.*;
import com.iflysse.dto.TeachingClassDto;
import com.iflysse.dto.TeachingClassUpdateDto;
@Service //服务层 
public class TeachingClassServiceImpl implements TeachingClassService{
	@Autowired
	private TeachingClassDao teacherClassDao;
	
	@Override
	public List<TeachingClassVo> findTeacherClass(String userId) {
		
		List<TeachingClass> t = teacherClassDao.getTeacherClass(userId);		
		List<TeachingClassVo> list = new ArrayList<>();
		for(TeachingClass tc : t) {
			list.add(CommonUtil.objToObj(tc, TeachingClassVo.class));	//反射完成
		}		
		return list;
	}
	
	@Override
	public int addTeacherClass(TeachingClassDto teachingClassDto) {
		return teacherClassDao.addTeachingClass(teachingClassDto);
	}

	@Override
	public int deleteTeacherClass(String userId,String classId) {
		// TODO Auto-generated method stub
		return  teacherClassDao.deleteTeachingClass(userId,classId);
	}

	@Override
	public int updateTeacherClass(TeachingClassUpdateDto form) {
		// TODO Auto-generated method stub
		return teacherClassDao.updateTeachingClass(form);
	}
	
	@Override
	public TeachingClassDetailVo queryClassInfoById(String classId) {
		TeachingClassDetailVo tc = teacherClassDao.getTeachingClassByClassId(classId);
//		TeachingClass ct=	teacherClassDao.getCourseAndTeacherName(tc.getTeacherId());		
//		CommonUtil.objToObj(tc, TeachingClassDetailVo.class);	//反射完成
		
		return CommonUtil.objToObj(tc, TeachingClassDetailVo.class);
	}



	
}
